<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Admin
 *
 *
 */
class GalleryContentController extends ContentController {
	//TODO - Insert your code here
	/**
	 * Edit the content
	 * (non-PHPdoc)
	 * @see ContentController::edit()
	 */
	public function edit($id){
		//$content_dao = ContentLineManager::GetEditor(ContentLineManager::GALLERY);
		$sectiondao = ContentLineManager::GetContentDao( $this->input->post( 'content_id' ) );
		$editing = $sectiondao->doGetObject( $id );		
		$display = $editing->GetEditorDisplay();
		$display->refurl = Request::prop('refurl');
		$display->action = 'edit/edit_action';
		$display->id = $id;
		$display->content_id = Request::prop('content_id');
		$display->selectedIds = $editing->selectedIds;
		$display->finalize();
		return $display;
	}
	/**
	 * Create the content
	 * (non-PHPdoc)
	 * @see ContentController::create()
	 */
	public function create($contentid){
		$content_dao = ContentLineManager::GetEditor(ContentLineManager::GALLERY);
		$content_dao->content_id = $contentid;
		$display = $content_dao->GetEditorDisplay();
		$display->refurl = Request::prop('refurl');
		$display->action = 'edit/create_action';
		$display->id = $contentid;
		$display->finalize();
		return $display;
	}
	/**
	 * Create the action
	 * (non-PHPdoc)
	 * @see ContentController::create_action()
	 */
	public function create_action($contentid){
		$sectionmanager = ContentLineManager::GetContentDao($contentid);
		$content_dao = ContentLineManager::GetEditor( Request::prop('content_editor_type'),TRUE );
		$sIds = new StringCollection();
		$sIds->fromArray( Request::prop('selectedID') );
		$content_dao->selectedIds = $sIds;
		$content_dao->catId = Request::prop('catId');
		$content_dao->content_id = $contentid;
		$this->form_validation->set_rules('title', 'Title', 'trim|xss_clean');
		$content_dao->defaultThumbsize = Request::prop('defaultThumbsize');
		if ( $this->form_validation->run() != FALSE )
		{
			$content_dao->title = Request::prop('title');
		}
		$sectionmanager->addObject($content_dao);
		redirect( $this->input->post('refurl') );
	}
	
	/**
	 * Edit the content
	 * (non-PHPdoc)
	 * @see ContentController::edit_action()
	 */
	public function edit_action($id){
		$sectiondao = ContentLineManager::GetContentDao( $this->input->post( 'content_id' ) );
		// update section
		$editing = $sectiondao->doGetObject( $id );
		$sIds = new StringCollection();
		$sIds->fromArray( Request::prop('selectedID') );
		$editing->selectedIds = $sIds;
		$editing->catId = Request::prop('catId');
		print $editing->catId;
		$editing->defaultThumbsize = Request::prop('defaultThumbsize');
		$this->form_validation->set_rules('title', 'Title', 'trim|xss_clean');
		if ( $this->form_validation->run() != FALSE )
		{
			$editing->title = Request::prop('title');
		}
		redirect(Request::prop('refurl'));
	}

}


?>